<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let fn = function (data) {
        console.log("同步1" + data);
        return data;
      };
      let asyncFn = function (data) {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            console.log("异步2" + data);
            resolve(data);
          }, 1000);
        });
      };
      let fn2 = function (data) {
        console.log("同步2" + data);
        return data;
      };
      let chain = [];
      chain = [fn, asyncFn, fn2];

      (async function () {
        while (chain.length > 0) {
          let str = "promise传参";
          let fn = chain.shift();
          str = await fn(str);
        }
      })();
    </script>
  </body>
</html>
